//
//  ArrayQA.swift
//  Swift-LeetCode
//
//  Created by 卢悦明 on 2024/1/15.
//

import Foundation

class ArrayQA: NSObject {

    static func QAArrayList() {
        let array1 = ArrayList(defaultValue: 0)
        array1.add(0)
        array1.add(1)
        array1.add(2)
        array1.add(3)
        array1.remove(2)
        array1.printArray()
        array1.insert(2, 2)
        array1.printArray()


        for item in array1.elements[1..<3] {
            print("部分遍历********", item)
        }
        for index in 1..<5 {
            print("区间遍历********", index)
        }
        
        for (index, item) in array1.elements[0...2].enumerated() {
            print(index ,"**打印index和item********", item)
        }
        for (index, item) in array1.elements[0...2].reversed().enumerated() {
            print(index, "**倒序********", item)
        }
        
        print(array1.length, array1.elements)
        
        do {
            let element = try array1.get(20)
            print(element)
            print("++++++++++++++1")

        } catch let tem as StructError {
            print("________", tem.errorMsg)

        }  catch let customErro {
            print("**********8", customErro)
        }
    }
    
}
